package com.greensecurity.sim.controller;

import com.greensecurity.sim.entity.SystemMessage;
import com.greensecurity.sim.repository.SystemMessageRepository;
import com.greensecurity.sim.service.SystemMessageService;
import com.sun.org.apache.xpath.internal.operations.Bool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/systemMessage")
@Api(description = "系统消息接口")
public class SystemMessageController {

    @Resource
    private SystemMessageRepository systemMessageRepository;

    @Resource
    private SystemMessageService systemMessageService;

    @ApiOperation(value = "获取系统消息")
    @ResponseBody
    @GetMapping("/getSystemMessage")
    public List<SystemMessage> getSystemMessage(){
        return systemMessageRepository.findAll();
    }

    @ApiOperation(value = "查看消息是否已读")
    @ResponseBody
    @GetMapping("/findByIsRead/{isRead}")
    public List<SystemMessage> findByIsRead(@PathVariable Boolean isRead){
        return systemMessageService.findByIsRead(isRead);
    }



}
